package TopSky.IOT.JUnit.XStream.demo;
import java.util.ArrayList;
import java.util.List;

import Hia.Utils.XmlUtil;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JsonWriter.Format;
import com.thoughtworks.xstream.io.xml.DomDriver;

/**
 *@ClassName:PersonTest
 *@author: chenyoulong  
 *@date :2012-9-28 下午3:25:09
 *@Description:TODO 
 */
public class PersonTest {

    /** 
     * @Title: main 
     * @Description: TODO 
     * @param args 
     * @return void  
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        
        PersonBean per=new PersonBean();
        per.setFirstName("chen");
        per.setLastName("youlong");
        
        
        telphone tel=new telphone();
        tel.setCode(137280);
        tel.setNumber("137280968");
        
        faxphone fax=new faxphone();
        fax.setCode(20);
        fax.setNumber("020221327");
        //per.setTel(tel);
        //per.setFax(fax);
        List<PhoneNumber> phone=new ArrayList<PhoneNumber>();
        phone.add(tel);
        phone.add(fax);
        per.setPhone(phone);
        //测试一个标签下有多个同名标签
        List<String> friendList=new ArrayList<String>();
        friendList.add("A1");
        friendList.add("A2");
        friendList.add("A3");
        Friends friend1=new Friends();
        friend1.setName(friendList);
        per.setFriend(friend1);
        
        //测试一个标签下循环对象
        Animal dog=new Animal("Dolly",2);
        Animal cat=new Animal("Ketty",2);
        List<Animal> petList=new ArrayList<Animal>();
        petList.add(dog);
        petList.add(cat);
        Pets pet=new Pets();
        pet.setAnimalList(petList);
        per.setPet(pet);
        
                    //java对象转换成xml
        String xml=XmlUtil.toXml(per);
        System.out.println("xml===\n"+xml);
        
    }
}